<?php

namespace app\model\shop;

use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;
use think\Model;

class Shop extends BaseModel
{
    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'shop';

    use ModelTrait;


    /**
     * @param Model $query
     * @param $value
     * @param $data
     */
    public function searchPidAttr($query, $value, $data)
    {
        if ($value) {
            $query->where('pid', $value);
        }
    }

    /**
     * @param Model $query
     * @param $value
     * @param $data
     */
    public function searchChannelAttr($query, $value, $data)
    {
        if ($value) {
            $query->where('channel', $value);
        }
    }

    /**
     * @param Model $query
     * @param $value
     * @param $data
     */
    public function searchTitleAttr($query, $value, $data)
    {
        $query->where('title', 'like', '%' . $value . '%');
    }
}